//-----------------------------------------------------------------------
// <copyright file="ConPointService.cs" company="Pyramid Consulting">
//     Copyright (c) Pyramid Consulting. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using MyFramework;
using MIMS.WRS.Entities;
using MIMS.WRS.Data;
    
namespace MIMS.WRS.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class ConPointService
    {
        #region ConPoint

        public static void CreateConPoint(ConPoint conPoint)
        {            
            try
            {
                ConPointDAO conPointDAO = new ConPointDAO();
                conPointDAO.CreateConPoint(conPoint);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreateConPointException, ex);
            }
        }        

        public static void UpdateConPoint(ConPoint conPoint)
        {            
            try
            {
                ConPointDAO conPointDAO = new ConPointDAO();
                conPointDAO.UpdateConPoint(conPoint);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdateConPointException, ex);
            }
        }        

        public static void DeleteConPoint(int conPointID)
        {            
            try
            {
                ConPointDAO conPointDAO = new ConPointDAO();
                conPointDAO.DeleteConPoint(conPointID);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeleteConPointException, ex);
            }
        }
        
        public static ConPoint GetConPoint(int conPointID)
        {            
            try
            {
                ConPointDAO conPointDAO = new ConPointDAO();
                return conPointDAO.GetConPoint(conPointID);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetConPointException, ex);
            }
        }                

        public static ConPointCollection GetConPoints(ConPointColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                ConPointDAO conPointDAO = new ConPointDAO();
                return conPointDAO.GetConPoints(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetConPointsException, ex);
            }
        }        

        public static ConPointCollection GetConPoints(ConPointColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                ConPointDAO conPointDAO = new ConPointDAO();
                return conPointDAO.GetConPoints(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetConPointsException, ex);
            }
        }        

        #endregion

		public static ConPoint GetConPoint(string description)
		{            
			try
			{
				ConPointDAO conPointDAO = new ConPointDAO();
				return conPointDAO.GetConPoint(description);                
			}
			catch (BusinessException)
			{
				throw;
			}
			catch (Exception ex)
			{
				// log this exception
				Logger.Error(ex);
				// wrap it and rethrow
				throw new BusinessException(SR.BusinessGetConPointException, ex);
			}
		}   

		public static int GetConPointBySupplier(string supplierNo) 
		{
			try
			{
				ConPointDAO conPointDAO = new ConPointDAO();
				return conPointDAO.GetConPointBySupplier(supplierNo);                
			}
			catch (BusinessException)
			{
				throw;
			}
			catch (Exception ex)
			{
				// log this exception
				Logger.Error(ex);
				// wrap it and rethrow
				throw new BusinessException(SR.BusinessGetConPointException, ex);
			}
		}
		
		public static ConPointCollection GetConPointsListForIDS()
		{            
			try
			{
				ConPointDAO conPointDAO = new ConPointDAO();
				return conPointDAO.GetConPointsListForIDS();
			}
			catch (BusinessException)
			{
				throw;
			}
			catch (Exception ex)
			{
				// log this exception
				Logger.Error(ex);
				// wrap it and rethrow
				throw new BusinessException(SR.BusinessGetConPointsException, ex);
			}
		}
    }
}